<?php
require_once './vendor/autoload.php';

// 生产者

$delay = new \Delay\DelayQueue();

$ttl            = 1000 * 30;//订单30s后超时
$delayExName    = 'delay-order-exchange';//超时exchange
$delayQueueName = 'delay-order-queue';//超时queue
$queueName      = 'ttl-order-queue';//订单queue

$delay->createQueue($ttl, $delayExName, $delayQueueName, $queueName);

//100个订单信息，每个订单超时时间都是10s
for ($i = 1; $i <= 100; $i++) {
    $data = [
    	'order_id' => $i,
    	'order_time' => time(),
    ];
    $delay->sendMessage(json_encode($data), $queueName);
    sleep(5);
}